imagesize
Quickly probe the size of various image formats without reading the entire file.
The goal of this crate is to be able to read the dimensions of a supported image without loading unnecessary data, and without pulling in more dependencies. Most reads only require 16 bytes or less, and more complex formats take advantage of skipping junk data.
Usage
Add the following to your Cargo.toml:
[]
= "0.12"
Supported Image Formats
- Aseprite
- BMP
- DDS
- EXR
- Farbfeld
- GIF
- HDR
- HEIC / HEIF
- ICO*
- JPEG
- JPEG XL
- KTX2
- PNG
- PNM (PBM, PGM, PPM)
- PSD / PSB
- QOI
- TGA
- TIFF
- VTF
- WEBP
If you have a format you think should be added, feel free to create an issue.
*ICO files can contain multiple images, imagesize
will give the dimensions of the largest one.
Examples
From a file
match size
From a vector
let data = vec!;
match blob_size